﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
namespace Business
{
    public partial class Customer
    {
        public static void GetAllForCombo(ref List<ComboItem> list, bool isAllOptions = false)
        {
            DataClassesDataContext context = null;
            try
            {
                context = new DataClassesDataContext(Common.Global.GetConnectionInfo().ConnectionStringSQL);
                var query = context.Customers;
                foreach (var item in query)
                {
                    ComboItem add = new ComboItem(item.ID, item.Name);
                    list.Add(add);
                }
                if (isAllOptions)
                    list.Insert(0, new ComboItem(0, "Tất cả"));
            }
            catch
            {
                list = null;
                return;
            }
            finally
            {
                context = null;
            }
        }

        public string GetName()
        { return Name; }
    }
}
